//    Copyright (C) Kherty.  All rights reserved.
namespace OpenLS.Vml.Parsing
{
    /// <summary>
    /// This class represents an attribute.  The AttDef is assigned
    /// from a validation process, and is used to provide default values.
    /// </summary>
    internal class Attribute
    {
        private string _literalValue; // tha attribute value
        private QualifiedName _qualifiedName; // the atomized name (using XmlNameTable).
        internal char QuoteChar; // the quote character used for the attribute value.
        public string LocalName { get { return _qualifiedName.LocalName; } }
        public string Prefix { get { return _qualifiedName.Prefix; } }
        public QualifiedName Name{get{return _qualifiedName;}}

        public string Value
        {
            get
            {
                if (_literalValue != null)
                    return _literalValue;
                return null;
            }
            set { _literalValue = value; }
        }

        public bool IsDefault
        {
            get { return (_literalValue == null); }
        }

        /// <summary>
        /// Attribute objects are reused during parsing to reduce memory allocations, 
        /// hence the Reset method. 
        /// </summary>
        public void Reset(QualifiedName fullName, string value, char quote)
        {
            _qualifiedName = (fullName);
            _literalValue = value;
            QuoteChar = quote;
        }
    }
}